<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="../static/css/prism.css" rel="stylesheet" />
</head>

<body>
    <h2>split方法（对照数组方法 join()）</h2>
    <p>按照给定规则分割字符串，返回一个由分割出来的子字符串组成的数组</p>
    <pre><code class="language-javascript">'it|sxt|baizhan'.split('|') // ["it", "sxt", "baizhan"]
'a|b|c'.split('') // ["a", "|",  "b","|", "c"]</code></pre>

    <p>省略参数，则返回数组的唯一成员就是原字符串</p>
    <pre><code class="language-javascript">'it|sxt|bz'.split() // ["it|sxt|bz"]</code></pre>

    <p>接受第二个参数，限定返回数组的最大成员数</p>
    <pre><code class="language-javascript">'it|sxt|bz'.split('|', 0) // []
'it|sxt|bz'.split('|', 1) // ["it"]
'it|sxt|bz'.split('|', 2) // ["it", "sxt"]
'it|sxt|bz'.split('|', 3) // ["it", "sxt", "bz"]
'it|sxt|bz'.split('|', 4) // ["it", "sxt", "bz"]</code></pre>

    <script>
        console.log("练习开始");
        console.log('it|sxt|bz'.split());
        console.log("练习结束");
    </script>

    <script src="../static/js/prism.min.js"></script>
</body>

</html>